/*
 * Copyright rgil2010
 * All rights reserved
 */

package com.test.gui.swing.components.panel;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author user
 */
public class lbzCmbProprietaire extends JPanel implements KeyListener{
    public lbzCmbProprietaire(String strText, int length){

        initializeComponents(strText, length);

    }
    private void initializeComponents(String strText, int length)
    {
        lblChamp = new JLabel();
        cmbChamp = new JTextField();
        cmbChamp.setEditable(true);
        //cmbChamp.addItem(makeObj("1"));
        //cmbChamp.addItem(makeObj("2"));
        cmbChamp.addKeyListener(this);

        lblChamp.setText(strText + " :");
        int d = lblChamp.getSize().width;
        javax.swing.GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);


        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(cmbChamp, GroupLayout.PREFERRED_SIZE, length, GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblChamp))
             )
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lblChamp)
                //.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbChamp,GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            )
        );

    }
   private Object makeObj(final String item)  {
     return new Object() { public String toString() { return item; } };
   }
 
    public String getText(){
        return "";//cmbChamp.get.getText();
    }
    JLabel lblChamp;
    JTextField cmbChamp;

    public void keyTyped(KeyEvent e) {
        System.out.println("tata");
    }

    public void keyPressed(KeyEvent e) {
        System.out.println("toto");
    }

    public void keyReleased(KeyEvent e) {
        System.out.println("titi");
    }

}
